/*
 * This source code is part of TWaver 4.0
 *
 * Serva Software PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 * Copyright 2002 - 2011 Serva Software. All rights reserved.
 */

package demo.network.miscellaneous.magnifier;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import twaver.TWaverUtil;
import twaver.network.InteractionMode;
import twaver.network.TNetwork;
import twaver.network.inputhandler.DefaultInputHandler;
import twaver.network.inputhandler.InputHandler;
import twaver.network.toolbar.BaseNetworkToggleButton;

public class MagnifierButton extends BaseNetworkToggleButton {

	public MagnifierButton(final TNetwork network) {
		super(network);
		this.setDefaultButtonGroup();
		this.setIcon(TWaverUtil.getIcon("/resource/image/network/pan.png"));

		this.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				if (isSelected()) {
					InputHandler[] listeners = new InputHandler[] {
							new DefaultInputHandler(network),
							new MagnifierHandler(network) };
					network.setInteractionMode(new InteractionMode(listeners));
				}
			}
		});
	}
}